import * as THREE from './node_modules/three/build/three.module.js';

export function animation() {
    const scene = new THREE.Scene();
    const renderer = new THREE.WebGLRenderer();
    renderer.setSize(window.innerWidth, window.innerHeight);
    document.body.appendChild(renderer.domElement);
    const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 500);
    camera.position.set(0, 0, 120);
    camera.lookAt(0, 0, 0);

    let s = "年轻人消失在白桦树林"
    const loader = new THREE.FontLoader();
    loader.load('./node_modules/three/examples/fonts/helvetiker_regular.typeface.json',
        function (font) { // 异步方法
            const geomery = new THREE.TextGeometry('Hello three.js!', {
                font: font,
                size: 5,
                height: 2,
                curveSegments: 12,
                bevelEnabled: false,
                bevelThickness: 1,
                bevelSize: 0.5,
                bevelSegments: 3
            })
            const material = new THREE.MeshBasicMaterial({ color: 0x0000ff });
            const mesh = new THREE.Mesh(geomery, material);
            mesh.position.set(-20, 0, 0);
            scene.add(mesh);
            function animate() {
                requestAnimationFrame(animate);
                mesh.rotation.x += 0.12;
                mesh.rotation.y += 0.1;
                renderer.render(scene, camera);
            }
            animate();
        })
}